﻿using System;
using System.Xml;
using log4net;
using log4net.Appender;
using log4net.Config;
using Truncation.Detector.Windows.Properties;

namespace Truncation.Detector.Windows
{
    public class Logger
    {
        private static Logger _instance;
        private static readonly string Detail = "detail_result.csv";
        private static readonly string Summary = "summary_result.csv";

        public static Logger CreateLogger(string detailFile, string summaryFile)
        {
            return _instance ?? (_instance = new Logger(detailFile, summaryFile));
        }

        private Logger(string detailFile, string summaryFile)
        {
            string detail = detailFile ?? Detail;
            string summary = summaryFile ?? Summary;
            string xml = Resources.LogConfig.Replace("_DETAIL_FILE_", detail).Replace("_SUMMARY_FILE_", summary);
      
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            var ret = log4net.Config.XmlConfigurator.Configure(doc.DocumentElement);

        }
    }
}